package Threadprojects.pro3_bestMatching.data.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

public class ReadData {
    public static List<String> read() throws IOException {
        List<String> rs = new ArrayList<>();
        Path path = Paths.get("src/main/java/Threadprojects/pro3_bestMatching/data/UK Advanced Cryptics Dictionary.txt");

        try (BufferedReader br = new BufferedReader(new InputStreamReader(Files.newInputStream(path)))) {
            String line;
            while ((line = br.readLine()) != null) {
                rs.add(line);
            }
        } catch (IOException e) {
            // 可以根据具体情况处理异常，例如日志记录或者向上抛出
            throw new IOException("无法读取文件", e);
        }

        return rs;
    }
}
